{extend name="main"}
{block name="style"}
{css href="__TEMPLATE_STATIC__/user.css"}
<style type="text/css">
	.inviteAnInterviewForm .el-dialog{min-width: 768px;}
	.inviteAnInterviewForm>.el-input, .inviteAnInterviewForm>.el-select{width: 40%;}
	.el-date-editor.el-input, .el-date-editor.el-input__inner{width: 100%;}
</style>
{/block}
{block name="header"}
{include file="module/user_top_nav"/}
{/block}
{block name="body"}
<div class="flex1 flex h-100">
	<div class="w-180px nav-left p-4 overflow-y-auto">
	{include file="module/user/company_left" left="module/user/company_left_resume"/}
	</div>
	<div class="frame-body flex-1 overflow-y-auto py-3">
		<div class="container-xl bg-white shadow" v-loading="search.ajax">
			<div class="flex">
				<div class="flex-1 block-title-before py-2">收到的简历</div>
				<div class="text-secondary pt-2">近两周(2020/03/26-至今)</div>
			</div>
			<div class="pt-4 flex text-center">
				<div class="pr-5">
					<div class="pt-3">
						<h4 class="text-info">{{statistics.resume_sum}}<span class="text-secondary" style="font-size: .7rem;">份</span></h4>
						<div class="pb-3 text-secondary">收到简历</div>
					</div>
				</div>
				<div class="pr-5">
					<div class="pt-3">
						<h4 class="text-info">{{statistics.not_resume_sum}}<span class="text-secondary" style="font-size: .7rem;">份</span></h4>
						<div class="pb-3 text-secondary">待处理简历</div>
					</div>
				</div>
				<div class="pr-5">
					<div class="pt-3">
						<h4 class="text-success">{{statistics.resume_efficiency}}<span class="text-secondary" style="font-size: .7rem;">%</span></h4>
						<div class="pb-3 text-secondary">简历查看率</div>
					</div>
				</div>
			</div>
			<div class="flex">
				<el-tabs v-model="search.status" class="bg-white flex-1" :before-leave="tabsChange">
					<el-tab-pane label="全部" name="all"></el-tab-pane>
					<el-tab-pane v-for="v in jobs_delivery" :label="v.title" :name="'status'+v.value"></el-tab-pane>
				</el-tabs>
				<div class="el-tabs el-tabs--top">
					<div class="el-tabs__header is-top">
						<div class="el-tabs__nav-wrap is-top">
							<div class="el-tabs__nav-scroll">
								<div class="py-2" style="font-size: 16px;">
									<el-checkbox v-model="search.is_stop_recruiting" :true-label="1" :false-label="0">包含停招职位</el-checkbox>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="pb-3">
				<el-form :model="search" ref="form" label-width="100px" label-position="right"  size="mini">
					<div class="flex">
					  <el-form-item label="简历姓名：" prop="resume_name" class="flex-1 mb-0">
						  <el-input
						    v-model="search.resume_name"
						    placeholder="输入简历姓名查找"
						    class="rounded-0">
						  </el-input>
					  </el-form-item>
					  <el-form-item label="应聘职位：" prop="jobs_id" class="flex-1 mb-0">
						  <el-select
						    v-model="search.jobs_id"
						    filterable
						    remote
						    reserve-keyword
						    placeholder="全部职位"
						    :remote-method="getJobsList"
						    class="rounded-0"
						    @focus="getJobsList">
						    <el-option :key="" value="">全部职位</el-option>
						    <el-option
						      v-for="item in jobsList"
						      :key="item.id"
						      :label="item.title"
						      :value="item.id">
						    </el-option>
						  </el-select>
					  </el-form-item>
					  <el-form-item label="简历来源：" prop="app_id" class="flex-1 mb-0">
						  <el-select
						    v-model="search.app_id"
						    filterable
						    remote
						    reserve-keyword
						    placeholder="不限"
						    :remote-method="getClientApp"
						    class="rounded-0"
						    @focus="getClientApp">
						    <el-option :key="" value="">不限</el-option>
						    <el-option
						      v-for="item in ClientApp"
						      :key="item.app_id"
						      :label="item.app_name"
						      :value="item.app_id">
						    </el-option>
						  </el-select>
					  </el-form-item>
					  <div class="flex-1"></div>
					  <div>
					  	<el-button type="primary" class="rounded-0" size="mini"
					  	@click="setPageChange(1)">查找</el-button>
					  </div>
					</div>
				</el-form>
			</div>
			<div class="table-responsive">
				<el-table
					ref="multipleTable"
			      	:data="tableData"
		    		stripe
		    		v-loading="search.ajax"
		    		style="width: 100%;"
		    		header-cell-class-name="bg-F4F4F4"
    				@selection-change="handleSelectionChange">
			      <el-table-column
			        type="selection"
			        width="50">
			      </el-table-column>
			      <el-table-column
			        prop="name"
			        label="ID"
			        width="100">
				      <template slot-scope="scope">
				      	<el-link :href="'/resume/'+scope.row.resume_id+'.html'"
				      	:underline="false"
				      	target="_blank">{{scope.row.id}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        prop="name"
			        label="名称"
			        width="100">
				      <template slot-scope="scope">
				      	<el-link :href="'/resume/'+scope.row.resume_id+'.html?jobs_id='+scope.row.jobs_id"
				      	:underline="false"
				      	target="_blank">{{scope.row.name}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        label="基本信息"
			        show-overflow-tooltip>
			        <template slot-scope="scope">
			        	{{XYBase.Date.getMStoYear(scope.row.age*1000)}}/
						<span v-if="scope.row.sex==1">男</span>
						<span v-else-if="scope.row.sex==2">女</span>
						<span v-else="scope.row.sex">未设置</span>
			        	/{{scope.row.educational_background}}/{{XYBase.Date.getMStoYear(scope.row.work_experience_time*1000)?XYBase.Date.getMStoYear(scope.row.work_experience_time*1000)+'年':'无'}}经验
			        </template>
			      </el-table-column>
			      <el-table-column
			        prop="title"
			        label="意向职位"
			        width="160">
				      <template slot-scope="scope">
				      	<el-link :href="'/jobs/'+scope.row.jobs_id+'.html'"
				      	:underline="false"
				      	target="_blank">{{scope.row.title}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        prop="create_time"
			        label="时间"
			        width="180">
			      </el-table-column>
			      <el-table-column
			        label="筛选"
			        width="80">
			        <template slot-scope="scope">
			        	<el-tag
						    v-for="item in jobs_delivery"
						    :key="item.title"
						    :type="item.type"
						    v-if="item.value == scope.row.status"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    {{ item.title }}
						</el-tag>
			        </template>
			      </el-table-column>
			      <el-table-column
			        label="操作"
			        width="140">
			        <template slot-scope="scope">
			        	<el-button-group class="text-nowrap" v-if="scope.row.status === 0 || scope.row.status === 1">
						  <el-button type="success" size="minism" 
						  @click="inviteAnInterview(scope.row)">邀请面试</el-button>
						  <el-button type="danger" size="minism" 
						  @click="setResumeInappropriate(scope.row);">不合适</el-button>
						</el-button-group>
			        	<el-button-group class="text-nowrap" v-if="scope.row.status === 2">
						  <el-button type="danger" size="minism" @click="delDeliveryResume(scope.row,scope.$index);">删除</el-button>
						</el-button-group>
			        </template>
			      </el-table-column>
			    </el-table>
			</div>
			<div class="pt-3">
				<el-button-group class="text-nowrap">
				  <el-button type="primary" size="mini"
				  @click="setDeliveryResumeViewedAll">设为已读</el-button>
				  <el-button type="danger" size="mini"
				  @click="delDeliveryResumeAll">删除</el-button>
				</el-button-group>
			</div>
			<div class="table-responsive py-3 text-center">
				<el-pagination
				  background
				  :hide-on-single-page="true"
				  @current-change="setPageChange"
			      :current-page="search.page"
			      :page-size="15"
			      layout="total,  prev, pager, next, jumper"
			      :total="search.total">
			    </el-pagination>
			</div>
		</div>
	</div>
</div>
<!-- 邀请面试 -->
<el-dialog
  :title="'邀请【'+inviteAnInterviewData.name+'】面试【'+inviteAnInterviewData.title+'】职位'"
  :visible.sync="dialogVisible"
  width="40%"
  class="inviteAnInterviewForm"
  :before-close="handleClose">
  <el-form :model="inviteAnInterviewForm" label-width="140px" :rules="rules" ref="inviteAnInterviewForm" size="small">
	  <el-form-item label="面试联系人" prop="contacts">
	    <el-input v-model="inviteAnInterviewForm.contacts" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="联系人电话" prop="contacts_mobile">
	    <el-input v-model="inviteAnInterviewForm.contacts_mobile" class="col-12 col-sm-5 pl-0 pr-0" maxlength="11"></el-input>
	  </el-form-item>
	  <el-form-item label="联系人固定电话">
	  	<div class="flex">
	  		<el-form-item prop="area_code" class="w-100px mb-0">
	    		<el-input v-model="tel.area_code" maxlength="4"></el-input>
	  		</el-form-item>
	  		<div class="px-1">-</div>
	  		<el-form-item prop="number" class="w-200px mb-0">
	    		<el-input v-model="tel.number" maxlength="8"></el-input>
	  		</el-form-item>
	  		<div class="px-1">-</div>
	  		<el-form-item prop="extension" class="w-100px mb-0">
	    		<el-input v-model="tel.extension" maxlength="6"></el-input>
	  		</el-form-item>
	  	</div>
	  </el-form-item>
	  <el-form-item label="联系人邮箱" prop="contacts_email">
	    <el-input v-model="inviteAnInterviewForm.contacts_email" class="col-12 col-sm-5 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="面试地址" prop="address">
	    <el-input v-model="inviteAnInterviewForm.address" class="col-12 col-sm-7 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="面试日期">
	  	<div class="flex">
	  		<el-form-item prop="interview_date" class="mb-0 flex-1">
			    <el-date-picker
			      v-model="inviteAnInterviewForm.interview_date"
			      type="date"
			      placeholder="面试日期"
			      format="yyyy 年 MM 月 dd 日"
			      value-format="timestamp"
			      :picker-options="{disabledDate:(time)=>{return time.getTime() < Date.now()}}">
			    </el-date-picker>
	  		</el-form-item>
	  		<div class="px-2"></div>
	  		<el-form-item prop="interview_start_time" class="mb-0 flex-1">
			  	<el-time-select
				    placeholder="起始时间"
				    v-model="inviteAnInterviewForm.interview_start_time"
				    :picker-options="{
				      start: '07:00',
				      step: '00:30',
				      end: '18:30'
				    }">
				</el-time-select>
	  		</el-form-item>
	  		<div class="px-1">-</div>
	  		<el-form-item prop="interview_end_time" class="mb-0 flex-1">
			   	<el-time-select
				    placeholder="结束时间"
				    v-model="inviteAnInterviewForm.interview_end_time"
				    :picker-options="{
				      start: '07:00',
				      step: '00:30',
				      end: '18:30',
				      minTime: inviteAnInterviewForm.interview_start_time
				    }">
				</el-time-select>
	  		</el-form-item>
	  	</div>
	  </el-form-item>
	  <el-form-item label="面试备注" prop="remarks">
	    <el-input v-model="inviteAnInterviewForm.remarks" class="col-12 col-sm-7 pl-0 pr-0"></el-input>
	  </el-form-item>
  </el-form>
  <span slot="footer" class="dialog-footer">
	    <el-button @click="cancelInviteAnInterviewFormSubmit();">取 消</el-button>
	    <el-button type="primary" @click="submitForm('inviteAnInterviewForm');" :loading="inviteAnInterviewForm.ajax">{{inviteAnInterviewForm.ajax?'提交中...':'发送'}}</el-button>
  </span>
</el-dialog>
{/block}
{block name="footer"}
{include file="module/login"/}
{/block}
{block name="script"}
<script type="text/javascript">
	var jobs_delivery={xycms:statusalias name="jobs/delivery" serialize="json"/};
	
</script>
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			userInfo:UserInfo,
			loginTabs:XYBase.loginTabs,
			feedback:XYBase.feedback,
			jobs_delivery:jobs_delivery,
			dialogVisible:false,
			jobsList:[],
			ClientApp:[],
			inviteAnInterviewData:{},
			inviteAnInterviewForm:{
				ajax:false,
				id:'',
				contacts:'',
				contacts_tel:'',
				contacts_mobile:'',
				contacts_email:'',
				address:'',
				interview_date:'',
				interview_start_time:'',
				interview_end_time:'',
				remarks:'',
			},
			tel:{
				area_code:'',
				number:'',
				extension:'',
			},
			search:{
				is_stop_recruiting:0,
				status:'{notempty name=":request()->get('action')"}{:request()->get('action')}{else/}all{/notempty}',
				resume_name:'',
				jobs_id:'{notempty name=":request()->get('jobs_id')"}{:request()->get('jobs_id')}{else/}{/notempty}',
				app_id:'',
		    	ajax:false,
				total:0,
				page: 1
			},
			statistics:{
				resume_sum:'--',
				not_resume_sum:'--',
				resume_efficiency:'--'
			},
			tableData:[],
	        rules: {
	          contacts: [
	            { required: true, message: '请输入联系人', trigger: 'blur' },
	          ],
	          contacts_mobile: [
	            { required: true, message: '请输入联系人手机号', trigger: 'blur' },
	          ],
	          address: [
	            { required: true, message: '请输入面试地址', trigger: 'blur' },
	          ],
	          interview_date: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	          interview_start_time: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	          interview_end_time: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	        }
		},
		watch:{
		    view:XYBase.viewWatch,
		    loginTabs:XYBase.loginTabsWatch,
			userInfo:{
				handler(val,oldVal){
					if (!val.id) {
						window.location.reload();
					}
				},
				deep:true
			},
		    tel:{
				handler(val,oldVal){
					if (val.area_code && val.number) {
						this.inviteAnInterviewForm.contacts_tel=val.area_code+'-'+val.number;
						if (val.extension) 
							this.inviteAnInterviewForm.contacts_tel=val.area_code+'-'+val.number+'-'+val.extension
					}else{
						this.inviteAnInterviewForm.contacts_tel='';
					}
				},
				deep:true
			},
		},
		created(){
			XYBase.created(this);
			this.initHtml();
			this.initStatistics();
		},
		methods:XYBase.methods({
			toggleSelection(rows) {
				if (rows) {
				  rows.forEach(row => {
				    this.$refs.multipleTable.toggleRowSelection(row);
				  });
				} else {
				  this.$refs.multipleTable.clearSelection();
				}
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			tabsChange(activeName, oldActiveName){
				this.search.page=1;
				this.search.status=activeName;
				this.initHtml();
			},
			inviteAnInterview(row){
				this.inviteAnInterviewData=row;
				this.inviteAnInterviewForm.id=row.id;
				this.inviteAnInterviewForm.contacts=row.contacts.contacts;
				this.inviteAnInterviewForm.contacts_tel=row.contacts.contacts_tel;
				this.inviteAnInterviewForm.contacts_mobile=row.contacts.contacts_mobile;
				this.inviteAnInterviewForm.contacts_email=row.contacts.contacts_email;
				this.inviteAnInterviewForm.address=row.contacts.contacts_address;
				if (row.contacts.contacts_tel) {
					var telArr=row.contacts.contacts_tel.split('-');
					this.tel={
							area_code:telArr[0],
							number:telArr[1],
							extension:telArr[2]?telArr[2]:'',
						};
				}
				this.dialogVisible=true;
			},
			setResumeInappropriate(row){
				var _this=this;
				_this.$confirm('确定要将【'+row.name+'】投递的【'+row.title+'】职位设置为不合适吗？', '提示', {
					dangerouslyUseHTMLString:true,
		          	confirmButtonText: '确定',
		          	cancelButtonText: '取消',
		          	type: 'warning'
		        }).then(() => {
		        	_this.sendGet({
		        		url:'/user/resume/setResumeInappropriate/'+row.id
		        	},function(ret){
		        		if (ret) {
		        			if (ret.code === 0) {
								row.status=2;
		        			}else{
		        				XYBase.msg(ret.msg);
		        			}
		        		}
		        	});
		        }).catch(() => {
		        	XYBase.msg('已取消');
		        });
			},
			setDeliveryResumeViewedAll(){
				var _this=this;
				if(!this.multipleSelection.length)return XYBase.msg('请选择要操作的数据');
				loading = XYBase.openloading();
	        	_this.setDeliveryResumeViewedAllAjax(0);
			},
			setDeliveryResumeViewedAllAjax(index){
				var _this=this;
				var D=_this.multipleSelection[index];
				if (D) {
					loading.setText((index+1)+'/'+_this.multipleSelection.length);
					if (D.status===0) {
			        	_this.sendGet({
			        		url:'/user/resume/setDeliveryResumeViewed/'+D.id
			        	},function(ret){
			        		index++;
			        		if (ret) {
			        			if (ret.code === 0) D.status=1;
								_this.setDeliveryResumeViewedAllAjax(index);
			        		}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
						        _this.$refs.multipleTable.clearSelection();
			        		}
			        	});
		        	}else{
			        	index++;
						_this.setDeliveryResumeViewedAllAjax(index);
		        	}
				}else{
		          	loading.close();
			        _this.$refs.multipleTable.clearSelection();
				}
			},
			delDeliveryResumeAll(){
				var _this=this;
				if(!this.multipleSelection.length)return XYBase.msg('请选择要操作的数据');
				this.$confirm('确定要删除所选【'+this.multipleSelection.length+'】项吗？', '提示', {
					dangerouslyUseHTMLString:true,
		          	confirmButtonText: '确定',
		          	cancelButtonText: '取消',
		          	type: 'warning'
		        }).then(() => {
					loading = XYBase.openloading();
		        	_this.delDeliveryResumeAllAjax(0);
		        }).catch(() => {
		        	XYBase.msg('已取消');
		        });
			},
			delDeliveryResumeAllAjax(index){
				var _this=this;
				var D=_this.multipleSelection[index];
				if (D) {
					loading.setText((index+1)+'/'+_this.multipleSelection.length);
					if(D.status===2){
			        	_this.sendGet({
			        		url:'/user/resume/delDeliveryResume/'+D.id
			        	},function(ret){
			        		index++;
			        		if (ret) {
			        			if (ret.code === 0) D.status=1;
								_this.delDeliveryResumeAllAjax(index);
			        		}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
						        _this.$refs.multipleTable.clearSelection();
								location.reload();
			        		}
			        	});
		        	}else{
			        	index++;
						_this.delDeliveryResumeAllAjax(index);
		        	}
				}else{
		          	loading.close();
			        _this.$refs.multipleTable.clearSelection();
					location.reload();
				}
			},
			delDeliveryResume(row,index){
				var _this=this;
				_this.$confirm('确定要删除【'+row.name+'】投递的【'+row.title+'】职位吗？', '提示', {
					dangerouslyUseHTMLString:true,
		          	confirmButtonText: '确定',
		          	cancelButtonText: '取消',
		          	type: 'warning'
		        }).then(() => {
		        	_this.sendGet({
		        		url:'/user/resume/delDeliveryResume/'+row.id
		        	},function(ret){
		        		if (ret) {
		        			if (ret.code === 0) {
								_this.tableData.splice(index,1);
		        			}else{
		        				XYBase.msg(ret.msg);
		        			}
		        		}
		        	});
		        }).catch(() => {
		        	XYBase.msg('已取消');
		        });
			},
			setPageChange(val){
				this.search.page=val;
				this.initHtml();
			},
		    handleClose(done) {
		        this.$confirm('确认关闭面试邀请？')
		          .then(_ => {
				  	if (!this.inviteAnInterviewForm.ajax)
			            done();
		          })
		          .catch(_ => {});
	      	},
			submitForm(formName) {
				var _this=this;
		        this.$confirm('确认无误后发送邀请，发送后将不可撤回。')
		          .then(_ => {
					_this.$refs[formName].validate((valid) => {
					  if (valid) {
					  	_this.inviteAnInterviewForm.ajax=true;
					  	_this.sendPost({
					  		url:'/user/resume/inviteAnInterview',
					  		data:_this.inviteAnInterviewForm
					  	},function(ret){
						  	_this.inviteAnInterviewForm.ajax=false;
							if (ret) {
								if (ret.code === 0) {
								  	_this.inviteAnInterviewData.status=3;
								  	_this.dialogVisible = false;
								}else if(ret.code===-605){
									_this.$confirm(ret.msg, '提示', {
										dangerouslyUseHTMLString:true,
							          	confirmButtonText: '去充值',
							          	cancelButtonText: '取消',
							          	type: 'warning'
							        }).then(() => {
							        	window.open('/user/vip/server');
							        }).catch(() => {
							        });
								}else XYBase.msg(ret.msg);
							}
					  	});
					  } else {
						return XYBase.warning('请先把表单填写完整。');
					  }
					});
		            done();
		          })
		          .catch(_ => {});
			},
			cancelInviteAnInterviewFormSubmit(){
			  	if (!this.inviteAnInterviewForm.ajax)
				  	this.dialogVisible = false;
			},
			initHtml(){
				var _this=this;
				_this.search.ajax=true;
				_this.sendGet({
					url:'',
					data:_this.search,
				},function(ret){
					_this.search.ajax=false;
					if (ret) {
						_this.tableData=[];
						_this.search.total=ret.data.total;
						if (ret.code === 0) {
							_this.tableData=ret.data.data;
						}else XYBase.msg(ret.msg);
					}
				});
			},
			getJobsList(){
				var _this=this;
				_this.sendGet({
					url:'/user/jobs/management',
					data:{
						status:'all',
						page: 1
					},
				},function(ret){
					if (ret) {
						_this.jobsList=[];
						if (ret.code === 0) {
							_this.jobsList=ret.data.data;
						}
					}
				});
			},
			getClientApp(){
				var _this=this;
				if(_this.ClientApp.length)return;
				_this.sendGet({
					url:'/ajax/getClientApp',
					data:{key:1}
				},function(ret){
					if (ret) {
						_this.ClientApp=[];
						if (ret.code === 0) {
							_this.ClientApp=ret.data;
						}
					}
				});
			},
			initStatistics(){
				var _this=this;
				_this.sendGet({
					url:'/user/resume/statistics'
				},function(ret){
					if (ret && ret.code === 0) _this.statistics=ret.data;
				});
			}
		})
	});
</script>
{/block}